namespace AlmKickstart.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Projects",
                c => new
                    {
                        ProjectId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Description = c.String(),
                        StartDate = c.DateTime(),
                        DueDate = c.DateTime(),
                        StatusId = c.Int(nullable: false),
                        ProjectTypeId = c.Int(nullable: false),
                        ParentProjectId = c.Int(),
                    })
                .PrimaryKey(t => t.ProjectId)
                .ForeignKey("dbo.Status", t => t.StatusId, cascadeDelete: true)
                .ForeignKey("dbo.ProjectTypes", t => t.ProjectTypeId, cascadeDelete: true)
                .ForeignKey("dbo.Projects", t => t.ParentProjectId)
                .Index(t => t.StatusId)
                .Index(t => t.ProjectTypeId)
                .Index(t => t.ParentProjectId);
            
            CreateTable(
                "dbo.Status",
                c => new
                    {
                        StatusId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.StatusId);
            
            CreateTable(
                "dbo.ProjectTypes",
                c => new
                    {
                        ProjectTypeId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        PluralName = c.String(),
                        ParentProjectTypeId = c.Int(),
                        ProjectType_ProjectTypeId = c.Int(),
                    })
                .PrimaryKey(t => t.ProjectTypeId)
                .ForeignKey("dbo.ProjectTypes", t => t.ParentProjectTypeId)
                .ForeignKey("dbo.ProjectTypes", t => t.ProjectType_ProjectTypeId)
                .Index(t => t.ParentProjectTypeId)
                .Index(t => t.ProjectType_ProjectTypeId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.ProjectTypes", new[] { "ProjectType_ProjectTypeId" });
            DropIndex("dbo.ProjectTypes", new[] { "ParentProjectTypeId" });
            DropIndex("dbo.Projects", new[] { "ParentProjectId" });
            DropIndex("dbo.Projects", new[] { "ProjectTypeId" });
            DropIndex("dbo.Projects", new[] { "StatusId" });
            DropForeignKey("dbo.ProjectTypes", "ProjectType_ProjectTypeId", "dbo.ProjectTypes");
            DropForeignKey("dbo.ProjectTypes", "ParentProjectTypeId", "dbo.ProjectTypes");
            DropForeignKey("dbo.Projects", "ParentProjectId", "dbo.Projects");
            DropForeignKey("dbo.Projects", "ProjectTypeId", "dbo.ProjectTypes");
            DropForeignKey("dbo.Projects", "StatusId", "dbo.Status");
            DropTable("dbo.ProjectTypes");
            DropTable("dbo.Status");
            DropTable("dbo.Projects");
        }
    }
}
